home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / IFF-RGFX / RGFX-Chunks.doc < prev    next >
Encoding:
Text File  |  1997-11-26  |  8.4 KB  |  256 lines

  1.  A typical structure of a RGFX file (recommended) :
  2.  
  3.  
  4.      FORM-RGFX
  5.  
  6.        RGHD     Image Header
  7.        RSCM     Screenmode information
  8.        RCOL     Color and transparency information
  9.        RBOD     The Graphics itself
  10.  
  11.  
  12.      Additional (optional) chunks should appear somewhere
  13.      between RCOL and RBOD.
  14.  
  15.  
  16.  RGFX - Basic chunks
  17.  ===================
  18.  
  19.    RGHD - RawGfx Bitmap Header
  20.    ---------------------------
  21.    ** This one replaces BMHD
  22.  
  23. struct RGHD
  24. {
  25.  ULONG rgfx_LeftEdge;     /* (see BMHD)                               */
  26.  ULONG rgfx_TopEdge;      /* (see BMHD)                               */
  27.  ULONG rgfx_Width;        /* (see BMHD)                               */
  28.  ULONG rgfx_Height;       /* (see BMHD)                               */
  29.  ULONG rgfx_PageWidth;    /* (see BMHD)                               */
  30.  ULONG rgfx_PageHeight;   /* (see BMHD)                               */
  31.  
  32.  ULONG rgfx_Depth;        /* 1-8         for RMBT_BYTEPLANAR8,
  33.                              1-8         for RMBT_BYTECHUNKY8,
  34.                               24         for RMBT_3BYTERGB24          */
  35.  ULONG rgfx_PixelBits;    /* 1-8         for RMBT_BYTEPLANAR8,
  36.                                8         for RMBT_BYTECHUNKY8,
  37.                               24         for RMBT_3BYTERGB24          */
  38.  ULONG rgfx_BytesPerLine; /* (width+7)/8 for RMBT_BYTEPLANAR8,
  39.                               width      for RMBT_BYTECHUNKY8,
  40.                               width*3    for RMBT_3BYTERGB24          */
  41.  
  42.  ULONG rgfx_Compression;  /* RCMP_ type flag                          */
  43.  ULONG rgfx_XAspect;      /* (see BMHD)                               */
  44.  ULONG rgfx_YAspect;      /* (see BMHD)                               */
  45.  ULONG rgfx_BitMapType;   /* RBMT_ type flag                          */
  46. };
  47.  
  48.  
  49.  If you encounter unknown depth/pixelbits/bytesperline combinations,
  50.  then do reject these (future expansions). But so far, only use
  51.  the legal, defines ones yourself ! Don't define own formats,
  52.  e.g. for 16 Bit or for BGR !
  53.  
  54.  
  55. #define RCMT_NOCOMPRESSION  (0L)
  56. #define RCMT_XPK            (1L)
  57.  
  58. #define RMBT_BYTEPLANAR8    (0L)   /* unaligned planar 8 bit bitmap */
  59. #define RMBT_BYTECHUNKY8    (1L)   /* unaligned chunky 8 bit bitmap */
  60. #define RMBT_3BYTERGB24     (2L)   /* 3-byte 24 bit RGB triples     */
  61.  
  62.  BYTEPLANAR8 data is similar to a regular bitmap (or an ABIT data chunk),
  63.  with the exeception, that no alignment, i.e. to word boundaries, does
  64.  take place - in general, we don't make use of alignment.
  65.  
  66.  
  67.    RSCM - RawGfx ScreenMode
  68.    ------------------------
  69.    ** This one replaces CAMG.
  70.  
  71.    The default setting is:
  72.  
  73.    rscm_AGA:  default screenmode
  74.    rscm_CGfx: INVALID_ID
  75.    rscm_P96:  INVALID_ID
  76.  
  77.    if ModeNotAvailable( rscm_P96 ) does return an error,
  78.    then try ModeNotAvailable( rscm_CGfx ) - on error,
  79.    then try ModeNotAvailable( rscm_AGA ).
  80.  
  81.    Use the first ID, which is available, otherwise compute
  82.    one yourself by using BestModeID()
  83.  
  84. struct RSCM
  85. {
  86.  ULONG rscm_AGA;  /* 32 Bit AGA  Viewmode ID */
  87.  ULONG rscm_CGfx; /* 32 Bit CGfx Viewmode ID */
  88.  ULONG rscm_P96;  /* 32 Bit P96  Viewmode ID */
  89. };
  90.  
  91.  
  92.  
  93.    RCOL - RawGfx Colormap
  94.    ----------------------
  95.    ** This one replaces CMAP,
  96.  
  97.       Required with RMBT_BYTEPLANAR8 and RMBT_BYTECHUNKY8,
  98.       and optionally allowed with RMBT_3BYTERGB24 for use
  99.       as a dithering destination colormap.
  100.  
  101.       Stored are 256 byte triples in RGB format. Note, that
  102.       full-range values (0..255) have to be stored.
  103.  
  104.       Sample:   rcol_Colors[0][0]   = 0..255 red   value, color #0 (1st)
  105.                 rcol_Colors[0][1]   = 0..255 green value, color #0
  106.                 rcol_Colors[0][2]   = 0..255 blue  value, color #0
  107.                 ...
  108.                 rcol_Colors[255][0] = 0..255 red   value, color #255 (256th)
  109.                 rcol_Colors[255][1] = 0..255 green value, color #255
  110.                 rcol_Colors[255][2] = 0..255 blue  value, color #255
  111.  
  112.  
  113.       Unused entries should be filled with zeroes.
  114.  
  115. struct RCOL
  116. {
  117.  ULONG rcol_TransColor;      /* boolean: is there a transparent color ?  */
  118.  ULONG rcol_TransColorNum;   /* yes, it's number ... from the ones below */
  119.  UBYTE rcol_Colors[256][3];
  120. };
  121.  
  122.    Allowed boolean values:  TRUE (1L) and FALSE (0L)
  123.  
  124.  
  125.    RBOD - RawGfx Bitmap Body
  126.    -------------------------
  127.    ** This one replaces BODY
  128.  
  129.  May look like:
  130.  
  131. struct RBOD
  132. {
  133.  UBYTE rbod_XPK[3];     ** containing 'XPK'
  134.  UBYTE rbod_BitMap[];
  135. };
  136.  
  137.  Or simply:
  138.  
  139. struct RBOD
  140. {
  141.  UBYTE rbod_BitMap[];
  142. };
  143.  
  144.  This has not been defined as a union structure here, since some
  145.  compilers may add unrequested pad bytes to the structure.
  146.  
  147.  You should reference this chunk as an UBYTE array, only.
  148.  
  149.  
  150.  RGFX - Optional chunks
  151.  ======================
  152.  
  153.    RXYA - Viewable XY-Area
  154.    -----------------------
  155.    ** based on an idea by Peter Bornhall <bornhall@swipnet.se>
  156.  
  157.       It may be useful to specify a small "view area" fromout
  158.       a larger image, e.g. a 320x200 area inside a 2048x2048
  159.       image.
  160.  
  161. struct RXYA
  162. {
  163.  ULONG xy_LeftEdge;
  164.  ULONG xy_TopEdge;
  165.  ULONG xy_Width;
  166.  ULONG xy_Height;
  167. };
  168.  
  169.  
  170.    RXXX - Image Rating
  171.    -------------------
  172.    ** based on an idea by Peter Bornhall <bornhall@swipnet.se>
  173.  
  174.       Not all images may be suitable for any group of recepients.
  175.  
  176. struct RXXX
  177. {
  178.  ULONG xxx_Rating; /* e.g. for parents who want to control access */
  179. };
  180.  
  181. #define RXXX_HARMLESS          (0L) /* this image won't affect anyone        (e.g. cliparts)       */
  182. #define RXXX_PARENTAL_ADVISORY (1L) /* some people may feel offended by this (e.g. violent comics) */
  183. #define RXXX_OFFENSIVE         (2L) /* most people will feel offended by this (whatever)           */
  184.  
  185.  
  186.    RALH - Alpha Channel Header
  187.    ---------------------------
  188.    ** based on an idea by Marcel Offermans <M.Offermans@CBi.CentraalBeheer.NL>
  189.  
  190.       We support three different types of Alpha channels:
  191.  
  192.         - operating on a colormap (with upto 8 bit images only, and
  193.           only, if MORE than one color should be transparent, i.e.
  194.           when RCOL.rcol_TransColor does not suffice). Like with RCOL,
  195.           the supplied table should be sized for 256 colors always, thus
  196.           any unused entries should be set to zero (= fully transparent).
  197.  
  198.         - operating on separate pixels (with any bitdepth),
  199.           supplying a width*height area of 0..255 values for
  200.           each pixel (or component), where 0 means "fully transparent"
  201.           and 255 means "not transparent at all"
  202.  
  203.       We also allow to differ between "complete" transparency and
  204.       "color component specific" transparency, i.e. you either may apply
  205.       the transparency to the whole RGB value of the color/pixel OR to each one
  206.       of the RGB color components separately (which means 3 times as much data).
  207.       This works with colormaps as well as pixelmaps.
  208.  
  209.       Examples:   - transparent colormap, for whole color
  210.  
  211.                       256 entries, each one ranged 0..255
  212.                       [ size: 256 bytes ]
  213.  
  214.                   - transparent colormap, for color components
  215.  
  216.                       256 triple entries, means
  217.                       three sub entries ranged 0..255 (for R, G and B)
  218.                       [ size: 768 bytes ]
  219.  
  220.                   - transparent pixelmap, for whole 8/24 Bit pixels
  221.  
  222.                       <width> x <height> entries, each one
  223.                       ranged 0..255
  224.                       [ size: width x height ]
  225.  
  226.                   - transparent pixelmap, for RGB components 8/24 Bit pixels
  227.  
  228.                       <width> x <height> entries, means each pixel with
  229.                       three sub entries ranged 0..255 (for R, G and B)
  230.                       [ size: width x height x 3 ]
  231.  
  232.                       This may not be practical for most uses, since it
  233.                       will double the space needed for a 24 bit graphics
  234.                       and will need four times the space for a 8 bit graphics.
  235.  
  236.  
  237. struct RALH
  238. {
  239.  ULONG ralh_AlphaType;            /* the type of alpha channel - colormap (8 bit)    */
  240.                                   /* or pixelmap (8/24 bit)                          */
  241.  ULONG ralh_TransparencyType;     /* Completely or for a single component, only ?    */
  242. };
  243.  
  244. #define RALH_TYPE_PIXEL (0L)      /* 8/24 bit: (non)transparacy value for each pixel */
  245. #define RALH_TYPE_CMAP  (1L)      /* upto 8 Bit, only: supplies another colormap     */
  246.  
  247. #define RALH_TRANS_ALL       (0L) /* one 0.255 value for all components              */
  248. #define RALH_TRANS_COMPONENT (1L) /* one 0.255 value for each, separate component    */
  249.  
  250.  
  251.  RGFX - Other chunks
  252.  ===================
  253.  
  254.    - NAME, AUTH, ANNO and (C) chunks are allowed
  255.  
  256.